<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>初体验web worker</title>
  </head>
  <body>
    <!-- 文档地址 https://developer.mozilla.org/zh-CN/docs/Web/API/File/webkitRelativePath -->
    <input id="upload-directory" type="file" webkitdirectory multiple />
    <button id="cancel">取消</button>
    <script>
      const S3Worker = new Worker("/workers/upload.js");
      const uploadDirectoryInput = document.getElementById("upload-directory");
      uploadDirectoryInput?.addEventListener("change", (e) => {
        S3Worker.postMessage({ action: "uploads", payload: e.target.files });
      });
      const cancel = document.getElementById("cancel");
      cancel?.addEventListener("click", () => {
        S3Worker.postMessage({ action: "abort" });
      });
    </script>
  </body>
</html>
